/*
 * @Date: 2023-12-18 17:55:55
 * @LastEditors: 玄绮 shijiahansi@qq.com
 * @LastEditTime: 2024-03-10 15:51:13
 * @FilePath: \serverd:\dev-code\vscode\boost_chat\client\src\database\SQLiteUtils.h
 */
#ifndef SQLITEUTILS_H
#define SQLITEUTILS_H

#pragma once
#include <QtSql>
#include <data/UserInfo.pb.h>

#include "LoginAccount.h"

class SQLiteUtils {
private:
    // const QString DB_PATH = "C:/dev-tools/SQLite/test/test.db";
    const QString DB_PATH = "database/boost_chat.db";
public:
    SQLiteUtils();
    ~SQLiteUtils();

private:
    bool hasAccount(LoginAccount account);

public:
    bool hasFileInfo(QString fileUrl);
    bool insertFileInfo(QString fileUrl, QString hashcode);

    bool insertAccount(LoginAccount account);
    bool updateAccount(LoginAccount account);
    bool deleteAccount(LoginAccount account);
    bool pushAccount(LoginAccount account);
    QList<LoginAccount> getLoginAccounts();

private:
    void executeSqlFile(const QString& fileName, QSqlDatabase& db);
    bool initDatabase();

private:
    QSqlDatabase db;
};

#endif